package com.token.utils;

import com.google.common.collect.Lists;
import com.token.model.dto.MenuTreeResultDTO;

import java.util.List;

/**
 * @author: henriy
 * @Date: 2024/9/25
 */
public class MenuTestUtils {
    public static void main(String[] args) {
        List<MenuTreeResultDTO> menuList = makeMenuList();
        System.out.println("menuList init  ==" + menuList);
        //使用楼数
        ToTreeUtil<MenuTreeResultDTO, String> util = new ToTreeUtil<>(menuList, MenuTreeResultDTO::getMenuId,
                MenuTreeResultDTO::getParentId, MenuTreeResultDTO::setChildren, MenuTreeResultDTO::setLevel);
        menuList = util.build();
        System.out.println("menuList result==" + menuList);
    }

    public static List<MenuTreeResultDTO> makeMenuList() {
        List<MenuTreeResultDTO> menuList = Lists.newArrayList();
        MenuTreeResultDTO parentMenu = MenuTreeResultDTO.builder()
                .menuId("1000")
                .menuName("顶级父级菜单")
                .seq(1)
                .parentId("")
                .build();
        menuList.add(parentMenu);
        for (int i = 1; i < 4; i++) {
            MenuTreeResultDTO parentMenuDTO = MenuTreeResultDTO.builder()
                    .menuId("100" + i)
                    .menuName("一级父级菜单")
                    .seq(2)
                    .parentId("1000")
                    .build();
            menuList.add(parentMenuDTO);
        }

        return menuList;
    }

}
